Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support React 18 #423

Merged
merged 45 commits into from
Feb 20, 2024
Merged

Support React 18 #423

merged 45 commits into from
Feb 20, 2024

Conversation

jesuyedavid
Copy link
Contributor

@jesuyedavid jesuyedavid commented Feb 1, 2024

The following changes were made to support React 18:

  • Updated react and react-dom dev dependency versions from 17.0.2 to 18.2.0
  • Updated peer dependencies to allow React 18
  • Updated react-collapsed from v3.6.0 to v4.1.2 which supports React 18
  • Copied @reach/auto-id's useId hook with minor modifications from https://github.com/reach/reach-ui/blob/dev/packages/auto-id/src/reach-auto-id.ts. Because the peer dependencies of that library don't allow React 18, we weren't able to install it directly anymore. This useId hook uses React 18's useId hook if it's present and otherwise falls back to custom logic for React 16 and 17.
  • Added a new renderPin prop to MapboxMap to allows React 18 users to render custom JSX into the DOM node for the marker element. This gets around the issue of having to call createRoot from react-dom/client in MapboxMap. This was causing issues on React 16/17 sites because Vite and Webpack were unable to determine that the dynamic import of react-dom/client wouldn't be reachable, and tried to resolve the package unsuccessfully. Rather than force existing consumers of the repo to update their bundler config to exclude react-dom/client, we provide this optional prop to React 18 users if they want to use React 18 features in their custom pin component, or if they don't want to get the console warning about using ReactDOM.render if they use the PinComponent prop.

To support testing in React 18:

  • We are now fetching TextEncoder from utils when setting up the test environment because the new react-dom does not have it
  • @testing-library/react-hooks doesn't support React 18 and it's functionality has now been added to @testing-library/react in v14. Because of this, @testing-library/react was upgraded to v14.2.1, which only supports React 18, and @testing-library/react-hooks was removed from the dev dependencies. The GitHub workflow for testing React 16 and 17 was updated to manually downgrade @testing-library/react to v12 and install @testing-library/react-hooks. Custom logic is added so that if @testing-library/react-hooks is installed, it's renderHook method is used (i.e. React 16/17), and otherwise the renderHook method from @testing-library/react is used (React 18).

J=BACK-2911, BACK-2923
TEST=auto, manual

Updated the test-site to use the new React 18 app initialization and tested all updated components manually to ensure they're not broken. Did a local npm pack of the repo and successfully used it in Pages repos with React 17 and 18.

Some updates were also made to clean up our tests:

  • Upgraded @testing-library/user-event from v13.5.0 to v14.5.2, which makes async calls, so we no longer need waitFor. As part of this change, we started getting some new console errors when trying to navigate in tests by clicking links. This is because navigation is not defined in the jest jsdom environment. A util function was added to mock the console to remove these errors.
  • Updated the GitHub test workflow for React 16 and 17 to manually install optional swc libraries because the post install script doesn't seem to run properly after we install specific versions of react-related packages. More info at @swc/core threw an error when attempting to validate swc compiler options. swc-project/swc#5616 (comment)

@jesuyedavid jesuyedavid requested a review from a team as a code owner February 1, 2024 18:42
@benmcginnis
Copy link
Member

Seems like we need to fix all of the workflows

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

package-lock.json Outdated Show resolved Hide resolved
Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

Copy link

semgrep-app bot commented Feb 8, 2024

Legal Risk
The following dependencies were released under a license that is currently prohibited by your organization. Merging is blocked until this is resolved.
Recommendation:
Reach out to your security team or Semgrep admin to address this issue. In special cases, exceptions may be made for dependencies with violating licenses, however, the general recommendation is to avoid using a dependency under such a license

non-standard
mapbox-gl 2.15.0
mapbox-gl 2.15.0

J=BACK-2923
TEST=auto
test-site/package-lock.json Outdated Show resolved Hide resolved
test-site/package-lock.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@nmanu1 nmanu1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PR should point to develop rather than main

@jesuyedavid jesuyedavid changed the base branch from main to develop February 15, 2024 19:09
@nmanu1 nmanu1 changed the title upgrade to react18 file updates Support React 18 Feb 15, 2024
Copy link
Contributor

@nmanu1 nmanu1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we use ReactDOM.render in the MapboxMap. we'll need to update that use the local react version's rendering approach

src/components/MapboxMap.tsx Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
@nmanu1 nmanu1 merged commit 66fc567 into develop Feb 20, 2024
25 of 26 checks passed
@nmanu1 nmanu1 deleted the react18upgrade branch February 20, 2024 15:05
nmanu1 added a commit that referenced this pull request Feb 20, 2024
### Features
- Add `onDropdownInputChange` optional prop to `FilterSearch` component (#421)
- Support React 18 (#423)

### Fixes
- Resolve vulnerabilities (#422)
@nmanu1 nmanu1 mentioned this pull request Feb 23, 2024
nmanu1 added a commit that referenced this pull request Feb 23, 2024
### Features
- Added support for React 18 (#423)
- Added an optional `onDropdownInputChange` prop to `FilterSearch` (#421)

### Fixes
- Addressed vulnerabilities (#422)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants